package com.spring.soundsystem.CoreAOP;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class UserBeanProxy implements InvocationHandler {
    private Object targetObject;
    public UserBeanProxy(Object object){
        targetObject = object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        UserBeanImpl userBean = (UserBeanImpl) targetObject;
        String userName = userBean.getUserName();
        Object result = null;
        if(userName != null && !"".equals(userName)){
            result = method.invoke(targetObject, args);
        }
        return result;
    }
}
